package com.lsl.endworkvol.utils;

import java.util.Date;

import com.lsl.endworkvol.service.func.IActivityBulider;

public class StatusTool {
    public static void activityStatus(IActivityBulider bulider, String statusText, IFalseToDo falseToDo, ITrueToDo trueToDo) {
        Date dateToday = new Date();
        Date dateStart = bulider.build().getStartTime();
        Date dateEnd = bulider.build().getEndTime();
        Date dateSignUpStart = bulider.build().getSignUpStartTime();
        Date dateSignUpEnd = bulider.build().getSignUpEndTime();
        if(statusText == null || statusText.isEmpty()) {
            if (trueToDo != null) trueToDo.action();
            return;
        }
        if (dateToday.before(dateSignUpStart) && statusText.equals("未开始")) {
            if (trueToDo != null) trueToDo.action();
        } else if (dateToday.after(dateEnd) && statusText.equals("已结束")) {
            if (trueToDo != null) trueToDo.action();
        } else if (dateToday.after(dateSignUpEnd) && dateToday.before(dateStart) && statusText.equals("报名已结束")) {
            if (trueToDo != null) trueToDo.action();
        } else if (dateToday.after(dateSignUpStart) && dateToday.before(dateSignUpEnd) && statusText.equals("报名中")) {
            if (trueToDo != null) trueToDo.action();
        } else if (dateToday.after(dateStart) && dateToday.before(dateEnd) && statusText.equals("进行中")) {
            if (trueToDo != null) trueToDo.action();
        } else {
            if (falseToDo != null) falseToDo.action();
        }
    }

    @FunctionalInterface
    public interface IFalseToDo {
        void action();
    }

    @FunctionalInterface
    public interface ITrueToDo {
        void action();
    }
}
